package zzz.javademo.GUI;

import org.codehaus.groovy.runtime.powerassert.SourceText;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * Created by 隼 on 2016/12/14.
 */
public class Framedemo1 {
    public static void main(String[] args) {
        //创建窗体
        Frame f=new Frame("监视原理——窗体关闭案例");
        //设置窗体属性
        f.setBounds(400, 300, 300, 400);

        //让窗体关闭

        //事件源
        //事件：对窗体的处理
        //事件处理： 关闭窗体 System.exit（）
        //事件监听
		/*f.addWindowListener(new WindowListener() {

			@Override
			public void windowOpened(WindowEvent e) {
				// TODO Auto-generated method stub

			}

			@Override
			public void windowIconified(WindowEvent e) {
				// TODO Auto-generated method stub

			}

			@Override
			public void windowDeiconified(WindowEvent e) {
				// TODO Auto-generated method stub

			}

			@Override
			public void windowDeactivated(WindowEvent e) {
				// TODO Auto-generated method stub

			}

			@Override
			public void windowClosing(WindowEvent e) {
				// TODO Auto-generated method stub
				System.exit(0);

			}

			@Override
			public void windowClosed(WindowEvent e) {
				// TODO Auto-generated method stub

			}

			@Override
			public void windowActivated(WindowEvent e) {
				// TODO Auto-generated method stub

			}
		});*/

        //用适配器类改进


        f.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                // TODO Auto-generated method stub
                System.exit(0);
            }
        });





        //设置窗体可见
        f.setVisible(true);

    }
}
